# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=ruby-eventmachine
_gemname=eventmachine
pkgver=1.2.7
pkgrel=4
pkgdesc="Fast, simple event-processing library for Ruby programs"
url="https://github.com/eventmachine/eventmachine"
arch="all"
license="Ruby OR GPL-2.0-or-later"
checkdepends="ruby-test-unit"
makedepends="openssl1.1-compat-dev ruby-dev"
source="https://github.com/eventmachine/eventmachine/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	improve-line_protocol-speed.patch::https://github.com/eventmachine/eventmachine/commit/10fb0c47c9a030b716dacd4a8df7e34b2445169b.patch
	remove-debug-puts-from-connection.patch::https://github.com/eventmachine/eventmachine/commit/681bc4e995a3c860d08a22c48723eef2b7719ae4.patch
	fix-pure_ruby-intra-iteration-delete.patch::https://github.com/eventmachine/eventmachine/commit/e29ccdefbf4b753dfec513c2df17b3bf1b827425.patch
	fixes-for-process-status-in-ruby-3.patch::https://github.com/eventmachine/eventmachine/commit/daeb121fb5600cc0f4fc604fbf7d742578f26483.patch
	fix-intermittent-tests.patch
	test_httpclient2-increase-timeout.patch
	0001-OpenSSL-1.1.0-test-updates.patch
	0002-Update-runtime-files-for-TLS13-no-SSL-OpenSSL-lib-info.patch
	0003-Move-console-SSL-Info-code-to-em_test_helper.patch
	0004-Openssl-1.1.1-updates.patch
	0005-Increase-certificate-length.patch
	0006-Bump-TLS-version.patch
	gemspec.patch
	"
builddir="$srcdir/$_gemname-$pkgver"

build() {
	gem build $_gemname.gemspec
	gem install \
		--local \
		--install-dir dist \
		--ignore-dependencies \
		--no-document \
		--verbose \
		$_gemname
}

check() {
	# test_defers somtimes hangs
	GEM_PATH='./dist' ruby -Itests -e "Dir.glob './tests/**/test_*.rb', &method(:require)" -- \
		--verbose \
		--ignore-name=/^test_em_system_pid$/ \
		--ignore-name=/^test_invalid_address_bind_connect_dst$/ \
		--ignore-name=/^test_invalid_address_bind_connect_src$/ \
		--ignore-name=/^test_localhost$/ \
		--ignore-name=/^test_defers$/
}

package() {
	local gemdir="$pkgdir/$(ruby -e 'puts Gem.default_dir')"
	cd "$builddir"/dist

	mkdir -p "$gemdir"
	cp -r extensions gems specifications "$gemdir"/

	# Remove unnecessary files and rubbish...
	find "$gemdir"/extensions/ -name mkmf.log -delete

	cd "$gemdir"/gems/$_gemname-$pkgver
	rm -r ext/ lib/*.so
}

sha512sums="
768ec084903dce4c737cf564fce7886a3e7e5b7d4a89c2baea3e998130c53dc00488eaa2d8e9b0133d9e4d8fffbde80c3025403881486a7968c2d84425cc1f50  ruby-eventmachine-1.2.7.tar.gz
fdb494c999d41aef60fe32453bc0b1e7fb4000a826c964f2ca5e352406587c844105b1a8926f2e3620ec442234f60b7321d0d597f49415ee6a6971c533ee32a8  improve-line_protocol-speed.patch
7a5ba6abaa7935c4916e5bbdae9c298771ca0f5663ed96e3020d3fda2b61069f008994a83fb5000b4cb1ecd16d4d0b9b75a797005c54fc7e2da2b25bc5f27aad  remove-debug-puts-from-connection.patch
3394e55c19ee7c82c254d94e3bcf7f9d70cabddbff0a9f0e91745ff4ff9e4e08c94393e40308d397590003e5da1ab62729cda6b8d6d3848277bacd68ca21027f  fix-pure_ruby-intra-iteration-delete.patch
d654edc4ac4059b8b73225ea217a6746a60a10c8250bae6b4ec9c7f1157c9f064cdf9a0596618d45e136c544ffe97818a26930fcfb91e5d7b22c7d78da014d07  fixes-for-process-status-in-ruby-3.patch
4ad075db2839206f3caa4ff296d8555b560a2ec77623b3a868f669e33476157d2372e41c17533a4807041b7b80f97981611c9c6beb8f356f67b7ad01d6705392  fix-intermittent-tests.patch
7f5ae8511e5b0d9624853affe45ba555ad36b202cb4fe9675262177d6f1340b20c15d1296fd2a1c62a59bb1862fc945e6ec6cd7a2760fb6ff1d8926ea0a0bd2c  test_httpclient2-increase-timeout.patch
e98deb058f87b0e7f7830ee02c738d35037c42ed8eb9b24e13655d64fd026395ad2cec98ad9247732e27f3908e5c494fb6e6e7118348c4349f438d4bc7558438  0001-OpenSSL-1.1.0-test-updates.patch
f5b90ac939a543eef560cdb1049d6dff786ee221aea1244eb11dd307954b3236cc89dc197aaf76661f8e906b4cbadf8e8944efbeca1345bd83edb407fc625527  0002-Update-runtime-files-for-TLS13-no-SSL-OpenSSL-lib-info.patch
4bec319a0c452361ec5119fc20892ab8496087a03767ea539318bf35908835af034280d748b6cf504e7015c2d193dc3b38c669d2301b64f14f69d54760c9525d  0003-Move-console-SSL-Info-code-to-em_test_helper.patch
a70825d8c7bf42c803a214e58be1cb7996fb2017bd0abc65e231729a01b5e9ae9bfc3db01f5fa70366abc717fdc3474764c8d7cd238dc3154016717715edbea6  0004-Openssl-1.1.1-updates.patch
cba2a93258410ca1e22c2c86ace55d5a303758caa09111a832ba448a92dd6e554f32e745da182c2ec4144b1d58e14852e51f77d5452d82687f6792010c08f6a0  0005-Increase-certificate-length.patch
f37c88a7571a65007745258758ccbfa95bde122a2ef604022dc83cdfe5af239160feb6087b9cc49f64317f7669702ff42bef9d3ff58be3d5b86c9acaa228ee69  0006-Bump-TLS-version.patch
e996c5cf94baf4c38909ec5383fe6fcac2b870f936adf0ff020064575ce016569b66921169b786f2ad5304de8c086a0a23371bbec9cd2cb8b6dd3372c5aee3ae  gemspec.patch
"
